<template>
  <view>
    <headBar title="投诉与建议"></headBar>
    <view style="padding:10px;">
      <uni-section title="评分" type="line" padding>
        <uni-rate v-model="rateValue" size="18"/>
      </uni-section>
      <uni-section title="投诉与建议" type="line" padding>
        <uni-easyinput type="textarea" autoHeight v-model="complaint" max-size="510"
                       placeholder="请输入内容"></uni-easyinput>
      </uni-section>
      <uni-section title="联系方式" type="line" padding>
        <uni-easyinput v-model="phone" placeholder="请输入联系电话"/>
      </uni-section>
      <view>
        <button type="primary" @tap="sub">提交</button>
      </view>
    </view>
    <bootNav nav=""></bootNav>
  </view>
</template>

<script>
export default {
  data() {
    return {
      rateValue: 5,
      complaint: '',
      phone: ''
    };
  },
  methods: {
    sub() {
      var t = this;
      if (t.complaint === '') {
        uni.showToast({title: '请填写内容', icon: 'error', duration: 2000});
        return
      }
      if (t.phone === '') {
        uni.showToast({title: '请填写手机号码', icon: 'error', duration: 2000});
        return
      }
      t.x_request('api/user/complaint', {
        rate: this.rateValue,
        complaint: this.complaint,
        phone: this.phone
      }, function (t, res) {
        if (res.code === 1) {
          uni.showToast({
            title: '已成功提交', icon: 'success', duration: 2000, success: function () {
              setTimeout(function () {
                t.x_redirect('/pages/my/my')
              }, 2000);
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="less">

</style>
